import { defineComponent as F, toRef as G, reactive as I, computed as D, openBlock as o, createElementBlock as r, createElementVNode as d, unref as a, toDisplayString as u, createBlock as m, withCtx as y, createVNode as b, createCommentVNode as p, Fragment as O, h as S } from "vue";
import { g as w, c as U, d as H, i as J, b as v, az as T, aA as K, a as j, f as M } from "./vendor.CF2kwqqq.js";
import { i as Q, A as W } from "./index.Bbfhrq76.js";
const X = { class: "uno-yyv8gw" }, Y = {
  "flex-1": "",
  flex: "",
  "items-center": "",
  "justify-between": ""
}, Z = ["title"], ee = {
  "flex-1": "",
  "b-1": "",
  "b-solid": "",
  "b-gray-3": "",
  "p-x-12": "",
  "p-y-4": "",
  "rd-4": "",
  "box-border": "",
  "h-full": "",
  "min-w-300": ""
}, ae = { key: 0 }, le = { key: 1 }, te = { key: 2 }, ne = {
  key: 1,
  class: "c-#bbb"
}, se = {
  "min-w-100": "",
  "h-full": ""
}, ue = /* @__PURE__ */ F({
  __name: "attr-item",
  props: {
    nifi: {},
    descriptor: {},
    label: {},
    data: {},
    disabled: { type: Boolean }
  },
  setup(R) {
    const h = R, { nifi: s, label: _, descriptor: e, data: g } = h, k = G(h, "disabled"), c = I({ ...g }), i = e.name, n = D(() => ({ name: i, value: w(c, i), valueLabel: w(c, i), data: e, label: e.displayName, dynamic: e == null ? void 0 : e.dynamic, required: e == null ? void 0 : e.required, sensitive: e == null ? void 0 : e.sensitive, allowableValues: e == null ? void 0 : e.allowableValues })), C = (t, l) => {
      M(c, t, l), M(g, t, l);
    }, f = D(() => {
      var l;
      const t = w(c, i);
      if (typeof t == "string") {
        if (/^\#\{.*?\}$/.test(t))
          return "param";
        if (e.identifiesControllerService != null)
          return "cs";
        if (((l = e.allowableValues) == null ? void 0 : l.length) > 0)
          return "select";
      }
      return "text";
    }), q = async () => {
      await s.newDialog({ content: S(Q, { row: n.value, nifi: s, resetProperty: C }), showClose: !1, closeOnClickModal: !1 }).finish();
    }, L = async () => {
      const t = n.value.value;
      s.closeAllDialog(), await new Promise((l) => setTimeout(() => l(!0), 100)), s.openControllerService(t);
    }, $ = async () => {
      let t = null;
      await s.newDialog({
        content: S(W, { row: n.value, onChange: (l) => t = l }),
        title: "转换为参数",
        submitCall: async () => {
          if (!(t != null && t.name))
            return j.warning("请输入参数名称"), !1;
          try {
            return await s.api.addParameters(s.parameterContext, [{ parameter: t }]), C(i, `#{${t.name}}`), s == null || s.refreshParameters(), !0;
          } catch (l) {
            return console.error(l), j.error("转换参数失败"), !1;
          }
        }
      }).finish();
    };
    return (t, l) => {
      var x, V, P, E, N;
      return o(), r("div", X, [
        d("div", Y, [
          d("span", {
            truncate: "",
            "max-w-300": "",
            "m-r-2em": "",
            title: a(_) || ((x = a(e)) == null ? void 0 : x.displayName) || a(i)
          }, u(a(_) || ((V = a(e)) == null ? void 0 : V.displayName) || a(i)), 9, Z),
          (P = a(e)) != null && P.description ? (o(), m(a(U), {
            key: 0,
            content: a(e).description,
            "popper-class": "max-w-50vw"
          }, {
            default: y(() => [
              b(a(H), { class: "hover-c-#67C23A" }, {
                default: y(() => [
                  b(a(J))
                ]),
                _: 1
              })
            ]),
            _: 1
          }, 8, ["content"])) : p("", !0)
        ]),
        d("div", ee, [
          b(a(v), {
            class: "w-full h-full text-left justify-start",
            disabled: k.value,
            link: "",
            onClick: l[0] || (l[0] = () => q())
          }, {
            default: y(() => {
              var A, B;
              return [
                n.value.value ? (o(), r(O, { key: 0 }, [
                  ((A = n.value.allowableValues) == null ? void 0 : A.length) > 0 ? (o(), r("span", ae, u(((B = n.value.allowableValues.find((z) => z.allowableValue.value == n.value.value)) == null ? void 0 : B.allowableValue.displayName) || n.value.value), 1)) : n.value.sensitive ? (o(), r("span", le, u(new Array(n.value.value.length).fill("*").join("")), 1)) : (o(), r("span", te, u(n.value.valueLabel), 1))
                ], 64)) : (o(), r("span", ne, u(n.value.value == null ? "未设置值" : "空字符串"), 1))
              ];
            }),
            _: 1
          }, 8, ["disabled"])
        ]),
        d("div", se, [
          f.value == "param" ? (o(), m(a(v), {
            key: 0,
            link: "",
            title: "前往参数",
            type: "success",
            icon: a(T)
          }, null, 8, ["icon"])) : p("", !0),
          f.value == "cs" ? (o(), m(a(v), {
            key: 1,
            link: "",
            title: "前往控制器服务",
            type: "primary",
            icon: a(T),
            onClick: l[1] || (l[1] = () => L())
          }, null, 8, ["icon"])) : p("", !0),
          (N = (E = a(s)) == null ? void 0 : E.groupParameter) != null && N.id && f.value != "param" ? (o(), m(a(v), {
            key: 2,
            disabled: k.value,
            link: "",
            title: "转换为参数",
            type: "warning",
            icon: a(K),
            onClick: l[2] || (l[2] = () => $())
          }, null, 8, ["disabled", "icon"])) : p("", !0)
        ])
      ]);
    };
  }
});
export {
  ue as _
};
